home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Floppyshop 2
/
Floppyshop - 2.zip
/
Floppyshop - 2.iso
/
diskmags
/
0022-3.564
/
dmg-3451
/
data
/
musplay.dat
< prev
next >
Wrap
Text File
|
1987-04-21
|
8KB
|
305 lines
Mad Max/Count Zero music player.
Wheee the fibble.
Many's the time when I want to listen to some music before
including it in a program/screen whatever. So, rather than exit
STOS and use someone elses player, I did a little one which you
could call from STOS. It's now upto version 2.5, but I'm going to
re-write it this week so I'll give away this version this time and
I'll send the source to the new version into this mag as soon as I
can. The basic principle of playing music from STOS is very
simple:
Mad Max:
(assuming you've loaded a mad max tune into a bank)
dreg(0) = music number : call start (bank) : wait vbl
repeat : call start(back)+8 : wait vbl : until whatever
Count Zero:
dreg(0) = music number : call start (bank)
repeat : call start(back)+2 : wait vbl : until whatever
For Mad Max music the music number can be from 1 - 15, but it'll
usually just have one tune in it, and Count Zero is almost always
just set to 1. This will only work if your program is updating at
50 frames per socond of course, other wise it won't sound very
good at all.
So, here's my little music player...
50 on error goto 960
Set up error trap.
60 mode 0 : key off : hide : flash off : click off : curs off
Set up screen (no high res! 70hz is out!)
65 ICE$="ICE!" : ICE=leek(varptr(ICE$))
This string is always found at the beggining of ice-packed
data files. This justs sets up a variable to check for it.
70 reserve as work 8,32 : reserve as work 9,32
Reserve some memory for the rasters.
80 reserve as work 13,34
And some more memory for something else.
90 reserve as work 10,30000
Memory for the music file (if your music file is longer than
30k, then there's probably something up...)
130 DR=drive
Save old drive (ain't it a pain when a program leaves you on
the wrong drive?)
140 colour 0,0
150 colour 15,$777
Set up paper+pen colours.
160 pen 15
Erm, set the pen to 15...
170 show on
Mouse on.
180 cls physic
190 cls back
200 cls logic : wait vbl
Clear all of the screens.
220 cls physic,0,0,0 to 320,49
230 cls back,0,0,0 to 320,49
240 cls logic,0,0,0 to 320,49
Clear the top 50 pixels of each screen (dunno if this bit's
still needed actually).
250 for T=1 to 14
260 colour T,deek(start(13)+T*2)
270 next T
280 wait vbl
Reset palette.
290 centre "WHEEE THE FIBBLES MUSIC PLAYER. V2.5" : print
300 F$=file select$("*.MUS","LOAD A .MUS FILE, RETURN TO QUIT",4) : rem> FILE <
310 curs off
320 if F$="" then drive=DR : default : end : rem> EXIT <
Get the filename. If it's empty the exit.
330 hide on
Mouse off.
340 for T=0 to 14
350 colour T,0
360 next T
370 wait vbl
Black palette.
380 cls physic,0,0,0 to 320,49
390 cls back,0,0,0 to 320,49
400 cls logic,0,0,0 to 320,49
Clear the top 50 pixels again (???)
410 home
420 print "LOADING..."
Print a top-quality message.
430 open in #1,F$
440 L=lof(#1) : rem> GET LENGTH OF FILE <
450 close #1
Open the file and get it's length.
460 if length(10)<>0 then fill start(10) to start(10)+length(10),0
If the bank is there then clear it (hmmm...)
470 bload F$,10
Load the music file.
475 if leek(start(10))=ICE then print "DEPACKING"
: areg(0)=start(10) : dreg(0)=0 : call start(14)+28
: L2=dreg(0) : if L2>L then L=L2
Check if the file is pack-iced. If it is then de-pack it and
set the file-length variable to the length of the packed
file.
480 PS=8 : FLS=true : FLS2=false : CV=8
PS is the PoSition to jump to in the music file (8 for mad
max and 2 for count zero)
490 if (deek(start(10))<>$6000) or (deek(start(10)+4)<>$6000)
or (deek(start(10)+8)<>$6000) then gosub 850 : if PS<0 then goto 170
Is it mad max? If not then check if it's Count Zero. I know
that you can check by HUNTing for TFMX, but I find it's best
to make sure the file's ok (or was it saved with the ultimate
ripper???)
530 CUR=1
Music number to start playing.
540 cls physic,0,0,0 to 320,49
550 cls back,0,0,0 to 320,49
560 cls logic,0,0,0 to 320,49
Clear top 50 pixels (again, maybe they're very dirty).
570 fill start(8) to start(8)+length(8),0 : doke start(8)+8,$FFFF
580 for T=start(9) to start(9)+4 step 2 : : doke T,50 : next T
: doke start(9)+10,$FFFF : doke start(9)+6,49 : doke start(9)+8,1
Set up the rasters (I won't bother explaining it...)
590 dreg(0)=CUR : call start(10)
Initialise the music.
600 home
610 pen 15
620 centre "PLAYING MUSIC NUMBER"+str$(CUR)+" " : print
630 centre "USE FUNCTION KEYS TO CHANGE MUSIC" : print
640 centre "SPACE TO LOAD ANOTHER" : print
650 centre "FILE: "+(F$-".MUS")+" SIZE:"+str$(L) : print
660 if PS=2 then centre "TYPE: COUNT ZERO" else centre "TYPE: MAD MAX"
Print up the information.
670 repeat
Set up the main loop.
680 S=peek($FFFFFC02)
Get the scancode of and keypress. I can't use inkey$/scancode
'cos the rasters cut them out.
690 doke start(8),0 : doke start(8)+2,(psg(8)/2)*$100
: doke start(8)+4,(psg(9)/2)*$110 : doke start(8)+6,(psg(10)/2)*$101
: doke start(8)+8,0 : doke start(8)+10,$FFFF
Set up the colours of the rasters according to the volume of
each voice.
700 X=2 : for T=8 to 10 : if psg(T)=16 then doke start(8)+X,psg(X-2)*5
710 X=X+2 : next T
If the voice is using an evolope, then est the raster to the
colour according to the pitch of the voice.
720 areg(0)=$FF8240 : areg(1)=start(8) : areg(2)=start(9) : dreg(0)=1
: dreg(1)=1 : call start(15)+28
Draw the rasters.
730 dreg(0)=CUR : call start(10)+PS
Play the next bit of the music.
740 if FLS and psg(CV)<>OLDP and psg(CV)<>0 then poke $FFFF8800,14
: poke $FFFF8802,$40
If the drive light flag is true, then flash the drive light.
750 if FLS and psg(CV)=OLDP or psg(CV)=0 then poke $FFFF8800,14
: poke $FFFF8802,2
If the drive light flag is true, but the voice is off, turn
off the drive light.
760 OLDP=psg(CV) : swap FLS,FLS2
Hold the old psg level and swp the light-flag.
770 wait vbl
Hrrrum...
780 until (S>58 and S<69) or (S>83 and S<90) or (S=57) or (S>1 and S<5)
Until you press one of these keys. (functions, space or 1-3.
1-3 change the voice which affects the drive light).
790 if S=57 then bell : areg(0)=$FF8240 : areg(1)=start(8)
: areg(2)=start(9) : dreg(0)=0 : dreg(1)=1 : call start(15)+28
: wait vbl : poke $FFFF8800,14 : poke $FFFF8802,2 : goto 170
Pressed space, so disable the rasters and jump to the file-
selector.
800 if S>1 and S<5 then CV=(S-2)+8 : goto 670
1-3 so change the voice affecting the drive light.
810 if S>58 and S<69 then CUR=S-58 else CUR=S-73
A function key, so change the music number.
820 remCUR=F : rem> SET CUR TO FUNCTION KEY PRESSED <
An old crap line that I forgot to remove.
830 goto 590
Jump back and play it.
850 H=hunt(start(10) to start(10)+L,"Count")
: if H<>0 then PS=2 else PS=-1
Check if it's a Count Zero file and set PS if it is.
860 if PS>0 then return
If PS has been set, then return.
870 home : print "THAT DOES NOT SEEM TO BE A NORMAL"
880 print "MUSIC FILE."
890 repeat : until inkey$=" " : return
PS wasn't set, so it wasn't a music file (probably).
960 areg(0)=$FF8240 : areg(1)=start(8) : areg(2)=start(9)
: dreg(0)=0 : dreg(1)=0 : call start(15)+28 : wait vbl
Disable rasters (not always the best thing to do really, but
never mind).
970 print "ERROR!" : print "Line:";errl : print "Number:";errn : bell : end
1000 screen copy physic to back : colour 0,0 : wait vbl
Blah blah...
1010 show on : G$=file select$("*.MUS","Save a music file",8) : if G$="" then return
1020 bsave G$,start(10) to start(10)+L
1025 dreg(0)=CUR : call start(10) : rem> PLAY MUSIC 'CUR' <
1030 hide on : wait vbl : return
Erm, this was (and still is I suppose) a bit to save the
music file back out again.
note from editor: Mad max backwards is xam dam, whereas Count Zero
backwards is orez tnuoc.